package com.ujiuye.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/jsajax")
public class AjaxServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String num=req.getParameter("num");
        int nu=0;
        if (num!=null&&num.trim()!=""){
            nu=Integer.parseInt(num);
        }
        //获取响应输出流
        PrintWriter writer=resp.getWriter();
//        把新的点赞数响应给客户端
        writer.print(nu+1);
        writer.close();
    }
}
